package com.atgugui.springcloud.controller;

import com.atgugui.springcloud.service.PaymentFeignService;
import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * ClassName: OrderFeignController
 * Package: com.atgugui.springcloud.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-04
 * Time: 22:21
 */

@RestController
@Slf4j
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "/consumer/payment/get/{id}")
    public CommonResult<Payment> getPayment(@PathVariable("id") Long id) {
        System.out.println("id: " + id);
        return paymentFeignService.getPayment(id);
    }


    @GetMapping(value = "consumer/payment/feign/timeout")
    public String paymentFeignTimeout(){
        //ofenFeign 底层是ribbon 客户端默认等待1秒
        //就是openFeign就是默认等待一秒 超过就保存
        //在yml配置文件中配置 openFeign的依赖里面自带了ribbon 自己支持负载均衡
        //开始超时控制之后 也可以访问了
        return paymentFeignService.paymentFeignTimeout();

    }

}
